/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.system.utils;

public enum BusinessCode {
    SUCCESS(0,"success"),
    FAILURE(-1,"fail"),
    EXCEPTION(-2,"执行过程中发生异常"),
    NOT_LOGIN(10000,"未登录"),
    OPERATIONLOG_SPAN_YEAR(110001, "操作日志不能跨年查询"),
    OPERATIONLOG_FORMAT_ERROR(110002, "操作日志格式错误"),
    DICTTYPE_DUBLE_NAME_OR_KEY(120001,"新增的字典类型名称或者key与已存在的字典类型数据重复"),
    DICTTYPE_UPDATE_DATA_NOT_FOUND(120002,"要修改的字典类型记录不存在"),
    DICTTYPE_DELETE_HAVE_DATA(120014,"选中要删除的类型下有字典数据类型，无法删除"),
    DICTDATA_TYPEKEY_NOT_FOUNT(120003,"字典类型不存在"),
    DICTDATA_SIMPLEKEY_DOUBLE_LABEL(120004,"同一字典类型key下存在相同标签的字典数据"),
    DICTDATA_IS_REFERENCED(120015,"选中的字典数据在其他地方被引用了，无法删除"),
    DISTRICT_EMPTY_NAME(120005,"片区名称不能为空"),
    DISTRICT_EMPTY_CODE(120006,"片区编码为空，无法修改"),
    DISTRICT_EMPTY_CHANGE_DATA(120007,"未选中数据"),
    DISTRICT_EMPTY_DATA_NOT_EXISIT(120008,"数据不存在"),
    DISTRICT_EXISIT_CORP(120009,"片区下存在关联的水司"),
    MESSAGE_EMPTY_TITLE(120010,"消息标题不能为空"),
    MESSAGE_EMPTY_CONTENT(120011,"消息内容不能为空"),
    MESSAGE_EMPTY_RECEIVERCODE(120012,"消息接收人不能为空"),
    MESSAGE_NOT_EXISIT(120013,"MESSAGE_NOT_EXISIT"),
    ANNOUNCEMENT_EMPTY_TITLE(120016,"通知公告标题不为为空"),
    ANNOUNCEMENT_EMPTY_CONTENT(120017,"通知公告内容不为为空"),
    ANNOUNCEMENT_EMPTY_BEGINTIME(120018,"通知公告播报开始时间不为为空"),
    ANNOUNCEMENT_EMPTY_ENDTIME(120019,"通知公告播报结束时间不为为空"),
    ANNOUNCEMENT_EMPTY_ANNOUINDEX(120020,"通知公告排序不为为空"),
    ANNOUNCEMENT_EMPTY_CHANGE_DATA(120021,"未选中数据"),


    DICTTYPE_EMPTY_NAME(130001,"字典类型名称不能为空"),
    DICTTYPE_EMPTY_KEY(130002,"字典类型Key不能为空"),
    DICTTYPE_EMPTY_INDEX(130003,"字典类型Index(排序)不能为空"),
    DICTTYPE_EMPTY_UPDATE_DATA(130004,"修改的数据为空"),
    DICTTYPE_EMPTY_CHANGE_DATA(130005,"未选中数据"),
    DICTDATA_EMPTY_LABEL(130006,"字典数据标签不能为空"),
    DICTDATA_EMPTY_TYPEKEY(130007,"字典数据类型key不能为空"),
    DICTDATA_EMPTY_UPDATE_DATA(130008,"修改的数据为空"),
    DICTDATA_EMPTY_CHANGE_DATA(130009,"未选中数据"),
    DISTRICT_EMPTY_SAVE_DATA(130010,"没有要保存的数据"),
    MESSAGE_EMPTY_CHANGE_DATA(130011,"未选中数据"),
    ;
    private final int code;
    private final String description;

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    BusinessCode(int code, String description) {
        this.code = code;
        this.description = description;
    }
    public static BusinessCode valueOf(int value){
        return switch (value) {
            case 0 -> SUCCESS;
            case -1 -> FAILURE;
            case -2 -> EXCEPTION;
            case -3 -> NOT_LOGIN;
            case 120001 -> DICTTYPE_DUBLE_NAME_OR_KEY;
            case 120002 -> DICTTYPE_UPDATE_DATA_NOT_FOUND;
            case 120003 -> DICTDATA_TYPEKEY_NOT_FOUNT;
            case 120004 -> DICTDATA_SIMPLEKEY_DOUBLE_LABEL;
            case 120005 -> DISTRICT_EMPTY_NAME;
            case 120006 -> DISTRICT_EMPTY_CODE;
            case 120007 -> DISTRICT_EMPTY_CHANGE_DATA;
            case 120008 -> DISTRICT_EMPTY_DATA_NOT_EXISIT;
            case 120009 -> DISTRICT_EXISIT_CORP;
            case 120010 -> MESSAGE_EMPTY_TITLE;
            case 120011 -> MESSAGE_EMPTY_CONTENT;
            case 120012 -> MESSAGE_EMPTY_RECEIVERCODE;
            case 120013 -> MESSAGE_NOT_EXISIT;
            case 120014 -> DICTTYPE_DELETE_HAVE_DATA;
            case 120015 -> DICTDATA_IS_REFERENCED;
            case 120016 -> ANNOUNCEMENT_EMPTY_TITLE;
            case 120017 -> ANNOUNCEMENT_EMPTY_CONTENT;
            case 120018 -> ANNOUNCEMENT_EMPTY_BEGINTIME;
            case 120019 -> ANNOUNCEMENT_EMPTY_ENDTIME;
            case 120020 -> ANNOUNCEMENT_EMPTY_ANNOUINDEX;
            case 120021 -> ANNOUNCEMENT_EMPTY_CHANGE_DATA;
            case 130001 -> DICTTYPE_EMPTY_NAME;
            case 130002 -> DICTTYPE_EMPTY_KEY;
            case 130003 -> DICTTYPE_EMPTY_INDEX;
            case 130004 -> DICTTYPE_EMPTY_UPDATE_DATA;
            case 130005 -> DICTTYPE_EMPTY_CHANGE_DATA;
            case 130006 -> DICTDATA_EMPTY_LABEL;
            case 130007 -> DICTDATA_EMPTY_TYPEKEY;
            case 130008 -> DICTDATA_EMPTY_UPDATE_DATA;
            case 130009 -> DICTDATA_EMPTY_CHANGE_DATA;
            case 130010 -> DISTRICT_EMPTY_SAVE_DATA;
            case 130011 -> MESSAGE_EMPTY_CHANGE_DATA;
            default -> null;
        };
    }
}
